#include <iostream>
#include <pthread.h>

#include "Client.h"
#include <cstdlib>

using namespace std;

int main()
{
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2, 2), &wsaData);

    if (Client::getSingleClient()->startListen() != 0)
    {
        std::cerr << "exit" << std::endl;
        exit(-1);
    }

    pthread_t pid;
    pthread_create(&pid, NULL, Client::thread_accept, (void *)Client::getSingleClient());

//    system("pause");
flag:
    int port, n;
    string str;
    cin >> port >> n >> str;

    cout << "port:" << port << "str:" << str << endl;
    Client::getSingleClient()->startCon(port, "127.0.0.1", n, str);
goto flag;
    Client::getSingleClient()->stopListen();

    WSACleanup();
    return 0;
}
